package com.thf.task;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class TaskListener {

    @Resource
    JavaMailSender javaMailSender;
    @Value("${spring.mail.username}")
    String from;
    @RabbitListener(queues = "taskQueue")
    public void receiver(String str){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);
        message.setTo("1197944007@qq.com");
        message.setSubject("定时任务");
        message.setText(str);
        javaMailSender.send(message);
    }
}
